package com.example.administrator.capital.mine.second;

import android.app.Fragment;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.example.administrator.capital.R;
import com.example.administrator.capital.base.BaseBackFragment;
import com.example.administrator.capital.presenter.ItemsPresenter;
import com.example.administrator.capital.presenter.base.IViewRequest;
import com.example.administrator.capital.utils.PreferenceManager;
import com.example.administrator.capital.utils.ToastUtil;
import com.lzy.okgo.model.Response;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;


/**
 * A simple {@link Fragment} subclass.
 * 充值
 */
public class RechargeCountFragment extends BaseBackFragment {
    @BindView(R.id.et_money)
    EditText etMoney;
    Unbinder unbinder;
    private TextView mBack;
    private View view;
    private TextView commit;


    public RechargeCountFragment() {
        // Required empty public constructor
    }

    public static RechargeCountFragment newInstance() {
        Bundle args = new Bundle();
        RechargeCountFragment fragment = new RechargeCountFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_recharge_count, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        mBack = view.findViewById(R.id.app_title_back);
        commit = view.findViewById(R.id.commit);

    }

    @Override
    protected void setListener() {
        super.setListener();
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                _mActivity.onBackPressed();
            }
        });
        commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(etMoney.getText().toString())) {
                    ToastUtil.showShort("金额不能为空");
                } else {
                    start(RechargeWebFragment.newInstance(etMoney.getText().toString()));
                }
            }
        });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
